<template>
  <view class="middleware">
    <h2>{{contentTxt}}</h2>
    <button class="button" @click="handleOpenMini">打开小程序</button>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        appid:'',
        url:'',
        path:'',
        contentTxt:'点击以下按钮打开小程序'
      };
    },
    onLoad() {
      const routes = getCurrentPages()
      const params = routes[routes.length - 1].options
      let url = decodeURIComponent(params.url)
      console.log(params,'params-----------')
      this.appid = decodeURIComponent(params.appid)
      this.path = decodeURIComponent(params.path)
      this.$get(`/order/apps/${this.appid}`).then(res=>{
        if(res.code == '1') this.contentTxt = `点击以下按钮打开"${res.content}"`
      })
    },
    methods:{
      handleOpenMini(){
        if(this.appid){
          uni.navigateToMiniProgram({
            appId:this.appid,
            path:this.path
          })
          return;
        }
        this.$toast('缺少主要参数')
      }
    }
  }
</script>

<style lang="less" scoped>
.middleware{
  padding: 0 100rpx;
  text-align: center;
  h2{
    font-size: 36rpx;
    font-weight: 500;
    color: #26282A;
    margin: 400rpx 0 200rpx;
  }
  .button{
    margin: 0 auto;
    width: 400rpx;
    background: #58be6b;
    color: #fff;
  }
}
</style>
